import CommonHeader from '@/components/common-header/index'
export default {
  name: 'AreaSelector',
  components: {
    CommonHeader,
  },
  data() {
    return {
      areaList: this.$store.state.visitingArea.AreaList,
      areaNow: this.$store.state.visitingArea.nowArea,
      searchList: this.$store.state.visitingArea.AreaList,
    }
  },
  methods: {
    changeArea(area) {
      this.$store.commit('changeNowVisitingArea', area)
      // console.log(this.$store.state.visitingArea)
    },
    getNowArea(area) {
      this.changeArea(area)
      uni.navigateBack({
        delta: 1,
      })
    },
    searchArea(key) {
      this.searchList = this.areaList.filter((item) => {
        if (item.includes(key)) {
          return item
        }
      })
      if (!key) {
        this.searchList = this.areaList
      }
    },
  },
  mounted() {
    // console.log(this.$store.state.visitingArea.AreaList)
    // console.log(this.$store.state.visitingArea.nowArea)
  },
}
